<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>历史视频</title>

    <link href="css/video-js.min.css" rel="stylesheet">
    <style>
        body{background-color: #191919}
        .m{ width: 740px; height: 400px; margin-left: auto; margin-right: auto; margin-top: 100px; }
    </style>
    <script src="https://cdn.bootcss.com/jquery/1.7.1/jquery.min.js"></script>
    <script src="swfobject.js"></script>

</head>
<body>





<div class="m">

    <div id='my-flv' style="margin:0 auto; width:418px; height:238px">
        <object type="application/x-shockwave-flash" id="flashContent"
                name="SampleMediaPlayback" align="middle"
                data="SampleMediaPlayback.swf" width="418" height="238"
                style="visibility: visible;">
            <param name="quality" value="high">
            <param name="bgcolor" value="#000000">
            <param name="allowscriptaccess" value="sameDomain">
            <param name="allowfullscreen" value="true">
            <param id='flv-source' name="flashvars"
                   value="">

        </object>
    </div>


    <video id="my-video" class="video-js" controls preload="auto" width="740" height="400"
           poster="" data-setup="{}">
        <source src="" type="video/mp4">
        <!--<source src="jq22-sp.mp4" type="video/mp4">-->
        <!--<source src="shipin2.mp4" type="video/mp4">-->
        <!--<source src="http://localhost:63342/video6.6.2.js/宁波港务局飞行视频2.mp4" type="video/mp4">-->
        <!--<source src="http://119.167.104.238:8030/uploader/WRJSP/MP4/宁波港务局飞行视频2.mp4" type="video/mp4">-->
        <!--<source src="http://jq22com.qiniudn.com/jq22-sp.mp4" type="video/mp4">-->
        <p class="vjs-no-js">
            To view this video please enable JavaScript, and consider upgrading to a web browser that
            <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
        </p>
    </video>
    <script>
        function QueryString(item)
        {
            var sValue=location.search.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"))
            return sValue?sValue[1]:sValue
        }

        //flash 播放器
        var queryParameters = new Array();
        var flashVars = "";
        var tag = "";
        var url = "";
        function initialise(div, type, url, height, width) {
            var wid = width ? width : 418;
            var hei = height ? height : 238;
            function getUrlParam(name) {
                name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var regexS = "[\\?&]" + name + "=([^&#]*)";
                var regex = new RegExp(regexS);
                var results = regex.exec(window.location.href);
                if (results == null)
                    return "";
                else
                    return unescape(results[1]);
            }
            queryParameters['source'] = getUrlParam('source');
            queryParameters['type'] = getUrlParam('type');
            queryParameters['idx'] = getUrlParam('idx');
            if (queryParameters['source'] == "")
                queryParameters['source'] = url;
            if (queryParameters['type'] == "")
                queryParameters['type'] = type;//"live","recorded";
            if (queryParameters['idx'] == "")
                queryParameters['idx'] = "2";
            flashVars += "&src=";
            flashVars += queryParameters['source'];
            flashVars += "&autoHideControlBar=";
            flashVars += unescape("true");
            flashVars += "&streamType=";
            flashVars += queryParameters['type'];
            flashVars += "&autoPlay=";
            flashVars += unescape("true");
            flashVars += "&verbose=";
            flashVars += "true";
            var soFlashVars = {
                src: queryParameters['source'],
                streamType: queryParameters['type'],
                autoPlay: "true",
                controlBarAutoHide: "true",
                controlBarPosition: "bottom"
            };
            tag = "&lt;object width='" + wid + "' height='" + hei + "' id='" + div + "' name='SampleMediaPlayback' type='application/x-shockwave-flash' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' &gt;&lt;param name='movie' value='SampleMediaPlayback.swf' /&gt; &lt;param name='quality' value='high' /&gt; &lt;param name='bgcolor' value='#000000' /&gt; &lt;param name='allowfullscreen' value='true' /&gt; &lt;param name='flashvars' value= '" +
                flashVars + "'/&gt;&lt;embed src='SampleMediaPlayback.swf' width='" + wid + "' height='" + hei + "' id='SampleMediaPlayback' quality='high' bgcolor='#000000' name='SampleMediaPlayback' allowfullscreen='true' pluginspage='http://www.adobe.com/go/getflashplayer'   flashvars='" + flashVars + "' type='application/x-shockwave-flash'&gt; &lt;/embed&gt;&lt;/object&gt;";
            var swfVersionStr = "10.3.0";
            var xiSwfUrlStr = "playerProductInstall.swf";
            var params = {};
            params.quality = "high";
            params.bgcolor = "#000000";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            var attributes = {};
            attributes.id = div;
            attributes.name = "SampleMediaPlayback";
            attributes.align = "middle";
            swfobject.embedSWF("SampleMediaPlayback.swf", div, wid, hei, swfVersionStr, xiSwfUrlStr, soFlashVars, params, attributes);
            swfobject.createCSS("#" + div, "display:block;text-align:left;");
        }

    </script>

    <script src="js/video.min.js"></script>
    <script type="text/javascript">

        //true为PC端，false为手机端
        function IsPC() {
            var userAgentInfo = navigator.userAgent;
            var Agents = ["Android", "iPhone",
                "SymbianOS", "Windows Phone",
                "iPad", "iPod"];
            var flag = true;
            for (var v = 0; v < Agents.length; v++) {
                if (userAgentInfo.indexOf(Agents[v]) > 0) {
                    flag = false;
                    break;
                }
            }
            return flag;
        }


        // var source_flv = "http://119.167.104.238:8030/uploader/WRJSP/0425舟山港航道.flv";
        // var source_url = "http://jq22com.qiniudn.com/jq22-sp.mp4";


        var source_url = QueryString('source_video');
        var web = QueryString('web');
        var website = 'http://119.167.104.238:8030';


        document.title = decodeURI( source_url.replace('.flv','').replace('.mp4','') );
        if( !IsPC() ){
            source_url = source_url.replace('.flv','.mp4');
        }


        source_type = '/WRJSP';
        var type = QueryString('type');
        if( type == 'hwsp'){
            source_type = '/HWSP';
        }

        if( web == 'soujiu' ){
            website = 'http://119.167.104.238:8040';
            source_type = '';
        }

        var source_flv_dir = website + '/uploader' + source_type + '/';
        var source_mp4_dir = website + '/uploader' + source_type + '/MP4/';

        function init(){

            //todo 检测是否超时， 有效期 为30分钟
            var t = QueryString('t');
            var now = (new Date()).getTime();
            if( t != null && t.length > 0 ){
                t = parseInt( t );
                var cha  = now - t;
                if( cha < 0 || cha > 60 * 30 * 1000 ){
                    alert('链接已失效');
                    return;
                }
            }else{
                alert('链接已失效');
                return;
            }

            if( source_url.toLowerCase().indexOf('.flv') > -1 ){
                source_url = source_flv_dir + source_url;
                // var url2 = 'http://119.167.104.238:8030/uploader/WRJSP/0425舟山港航道.flv';
                // console.log( url2 );
                console.log( source_url );
                initialise('flashContent', 0, source_url);

                $('#my-video').hide();

            }else if( source_url.toLowerCase().indexOf('.mp4') > -1 ){
                source_url = source_mp4_dir + source_url;
                var source_dom = document.getElementById('my-video').getElementsByTagName('source')[0];
                source_dom.src = source_url;

                var myPlayer = videojs('my-video');
                videojs("my-video").ready(function(){
                    var myPlayer = this;
                    myPlayer.play();
                });
                $('#my-flv').hide();
            }else{

                alert('没有找到合适的视频源');

            }
        }

        init();



    </script>
</div>
</body>
</html>